Math.constrain Method

Returns the closest value to value such that it is in the range (min, max).
 
 
Static This method is static.

Parameters

value

Type: Number
The value to constrain.
min

Type: Number - May be null
The smallest allowed value, or null if no lower limit exists.
max

Type: Number - May be null
The largest allowed value, or null if no upper limit exists.

Return Value


Type: Number
The value constrained to the range (min, max).